<template>
  <div class="my_div">
    <img
      :src=msg.dogImgUrl
      alt=""
    />
    <p @click="colorChange" :style="{backgroundColor:colorful}">{{msg.dogName}}</p>
  </div>
</template>

<script>
export default {
  props:['msg'],
  data() {
    return {
      colorful:'transparent',
      arr:['red','green','purple','orange','yellow','blue','pink']
    };
  },
  methods:{
    colorChange(){
        this.colorful=this.arr[parseInt(Math.random()*this.arr.length)]
        this.$emit('loveDog',this.msg.dogName)
    }
  },
};
</script>

<style>
.my_div {
  width: 200px;
  border: 1px solid black;
  text-align: center;
  float: left;
}

.my_div img {
  width: 100%;
  height: 200px;
}
</style>